#include "MatrixLED.h"
#include "Bytes4.h"

uchar timer0Counter;
uint graphCnt = sizeof(Bytes) / sizeof(uchar);
uint graphInd;

void main() {
	TMOD = 0x01;

	TF0 = 0;
	TR0 = 1;
	TH0 = 0xFC;
	TL0 = 0x18;
	ET0 = 1;
	PT0 = 0;
	
	EA = 1;

	while(1) {
		if(graphInd < graphCnt - 8)
			FlushMatrixLED(&Bytes[graphInd]);
		else P0 = 0xFF;

		if(timer0Counter >= 100) {
			timer0Counter -= 100;
			graphInd += 8;
		}
	}
}

void Timer0_Routine() interrupt 1
{
	if(P3_3) {
		TH0 = 0xFC;
		TL0 = 0x18;
	} else {
		TH0 = 0xFF;
		TL0 = 0x06;
	}
	timer0Counter++;
}
